(function (exports) {

    var $ = null;

    var DailyLayer = cc.Layer.extend({

        onEnter: function () {
            cc.Layer.prototype.onEnter.call(this);
        },
        onCCSLoadFinish: function () {
            var that = this;
        },
        onExit: function () {
            cc.Layer.prototype.onExit.call(this);
        },
        ctor: function () {
            this._super();

            var that = this;

            loadCCSTo(res.DailyLayer_json, this, "Layer");
            $ = create$(this.getChildByName("Layer"));
            shipei($);

            TouchUtils.setOnclickListener($('root.close'), function (node) {
                that.removeFromParent();
            });


            this.initDaily();


        },
        initDaily: function(){
            for(var i=0;i<31;i++){
                (function(i){
                    var daybg = $('root.daily.daybg' + i);
                    if(!daybg){
                        daybg = duplicateSprite($('root.daily.daybg0'));
                        daybg.setName('daybg' + i);
                        $('root.daily').addChild(daybg);
                    }
                    //700 440
                    daybg.setPosition(cc.p(i%7*100 + 50, 440 - Math.floor(i/7)*90 - 45));
                    TouchUtils.setOnclickListener(daybg, function (node) {
                        console.log(i);
                    });
                })(i);

            }
        },
    });
    exports.DailyLayer = DailyLayer;
})(window);
